print("序列化##################################################start")
import pickle

d = dict(name='Bob', age=20, score=88)
s = pickle.dumps(d)  # 序列化对象成bytes
print(s)
f = open('D:/dump.txt', 'wb')  # 写入权限
pickle.dump(d, f)  # 把对象序列化成字节 写入文件中
f.close()
f = open('D:/dump.txt', 'rb')  # 读取权限
s = pickle.load(f)  # 反序列化
f.close()
print(s)

import json

d = dict(name='Bob', age=20, score=88)
print(json.dumps(d))  # 转换成json

json_str = '{"age": 20, "score": 88, "name": "Bob"}'
print(json_str)
map = json.loads(json_str) # json转换成python对象
print(map["age"])

print("序列化##################################################end\n")
